home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / ctutor2.zip / SQUARES.C < prev    next >
C/C++ Source or Header  |  1987-07-04  |  502b  |  23 lines

  1.                                           /* Chapter 5 - Program 2 */
  2. main()  /* This is the main program */
  3. {
  4. int x,y;
  5.  
  6.    for(x = 0;x <= 7;x++) {
  7.       y = squ(x);  /* go get the value of x*x */
  8.       printf("The square of %d is %d\n",x,y);
  9.    }
  10.  
  11.    for (x = 0;x <= 7;++x)
  12.       printf("The value of %d is %d\n",x,squ(x));
  13. }
  14.  
  15. squ(in)  /* function to get the value of in squared */
  16. int in;
  17. {
  18. int square;
  19.  
  20.    square = in * in;
  21.    return(square);  /* This sets squ() = square */
  22. }
  23.